package com.mapproject.industrymap.controller;

import com.mapproject.industrymap.service.SysUploadFileService;
import com.mapproject.industrymap.utils.ReturnValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/file")
public class SysUploadFileController {
    @Autowired
    SysUploadFileService sysUploadFileService;
    @PostMapping("/upload")
    public ReturnValue uploadfile(@RequestParam("file") MultipartFile file,@RequestParam(value = "torowguid",required = false)String torowguid){

        return sysUploadFileService.uploadfile(file,torowguid);
    }
    @PostMapping("/uploadshp")//上传shp文件专用，不改文件名
    public ReturnValue uploadshpfile(@RequestParam("file") MultipartFile file,@RequestParam(value = "torowguid",required = false)String torowguid){

        return sysUploadFileService.uploadshpfile(file,torowguid);
    }
    @PostMapping("/uploaddxf")//上传dxf文件专用，不改文件名
    public ReturnValue uploaddxf(@RequestParam("file") MultipartFile file,@RequestParam(value = "torowguid",required = false)String torowguid){

        return sysUploadFileService.uploaddxf(file,torowguid);
    }

    @RequestMapping("/query")
    public ReturnValue queryInfo(@RequestParam(value = "torowguid",required = false)String torowguid){

        return sysUploadFileService.queryInfo(torowguid);
    }
    @RequestMapping("/delete")
    public ReturnValue deletefile(@RequestParam(value = "rowguid")String rowguid) throws IOException {

        return sysUploadFileService.deletefile(rowguid);
    }
    @RequestMapping("/exportfile")
    public ReturnValue exportfile() throws IOException {

        return sysUploadFileService.exportfile();
    }
}
